﻿// ———————————————————————–
// <copyright file="ProjectInstaller.cs" company="The MITRE Corporation">
//    Copyright (c) 2010 The MITRE Corporation. All rights reserved.
//    Licensed under the Apache License, Version 2.0 (the "License");
//    you may not use this file except in compliance with the License.
//    You may obtain a copy of the License at
//    http://www.apache.org/licenses/LICENSE-2.0
//    Unless required by applicable law or agreed to in writing, software
//    distributed under the License is distributed on an "AS IS" BASIS,
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//    See the License for the specific language governing permissions and
//    limitations under the License.
// </copyright>
// ———————————————————————–
/////////////////////////////////////////////////////////////////////////////////////////////////
// "ProjectInstaller".cs - "Installs The Services That Run The Core Router Services"
// Project: "IC.NETSOA"- "ICNETCoreRouter"
//
// Language:    C#, .NET 4.0
// Platform:    Windows 7, VS 2010
// Author:      Don McGarry The MITRE Corporation
/////////////////////////////////////////////////////////////////////////////////////////////////

// Copyright (c) 2010 The MITRE Corporation. All rights reserved.
//
// NOTICE
// This software was produced for the U. S. Government
// under Contract No. FA8721-09-C-0001, and is
// subject to the Rights in Noncommercial Computer Software
// and Noncommercial Computer Software Documentation Clause
// (DFARS) 252.227-7014 (JUN 1995)
                
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;

namespace ICNETCoreRouter
{
  /// <summary>
  /// Contains methods for installing the service that runs the Core Router.
  /// </summary>
  [RunInstaller(true)]
  public class ProjectInstaller : Installer
  {
    /// <summary>
    /// Used by the install utility to install the service.
    /// </summary>
    private ServiceProcessInstaller process;

    /// <summary>
    /// Also used by the install utility to start the service.
    /// </summary>
    private ServiceInstaller service;

    /// <summary>
    /// Initializes a new instance of the ProjectInstaller class.
    /// </summary>
    public ProjectInstaller()
    {
      this.process = new ServiceProcessInstaller();
      this.process.Account = ServiceAccount.NetworkService;
      this.service = new ServiceInstaller();
      this.service.ServiceName = "IC.NET Core Router";
      this.service.Description = "Core Router Application for the IC.NET Message Router";
      this.service.StartType = ServiceStartMode.Automatic;
      this.service.ServicesDependedOn = new string[] { "NetMsmqActivator", "MSMQ" };
      this.Installers.Add(this.process);
      this.Installers.Add(this.service);
    }
  }
}
